//# sourceURL=inviteCompanyEmpList.js
layui.element.on('tab(login-user-tabs)', function () {
    var currPage = 1;
    var inviteCompanyEmpList_fn = {
        initRender: function () {
            layui.table.render({
                id: 'inviteCompanyEmpListTableId',
                elem: '#inviteCompanyEmpList-table',
                url: '/inviteCompanyEmp/platformCompanyEmpList',
                height: 'full-170',
                page: true,
                limits: cmsUtils.getLimits(),
                limit: cmsUtils.getLimit(),
                cols:[[
                    {title: '<b>序号</b>',type: 'numbers',align: 'center',width: 80},
                    {title: '<b>姓名</b>',field: 'name',width: 180},
                    {title: '<b>职位</b>',field: 'jobTitleValue',width: 180},
                    {title: '<b>行业</b>',field: 'industry'},
                    {title: '<b>地址</b>',field: 'address'},
                    {title: '<b>创建时间</b>',field: 'createDate',align: 'center',width: 160},
                    {title: '<b>操作选项</b>',width: 160,align: 'center',toolbar: '#inviteCompanyEmpList-toolbar'}
                ]],
                done: function (res, curr, count) {
                    currPage = curr;
                    $('#inviteCompanyEmpList').attr('hasRender', true);
                }
            });
        },
        reload: function (page) {
            layui.table.reload('inviteCompanyEmpListTableId', {
                page:{
                    curr: page ? page : currPage
                }
            });
        },
        refreshList: function () {
            if ($('#inviteCompanyEmpList')[0]) {
                inviteCompanyEmpList_fn.reload(currPage);
            }
        },
        refreshList: function () {
            if ($('#inviteCompanyEmpList')[0]) {
                inviteCompanyEmpList_fn.reload(currPage);
            }
        },
        resetSearch: function () {
            inviteCompanyEmpList_fn.reload(1);
        }
    }
    if (!$('#inviteCompanyEmpList').attr('hasRender')) {
        inviteCompanyEmpList_fn.initRender();
        // 监听当前Tab页点击
        $(this).bind('tabClick', function () {
            inviteCompanyEmpList_fn.refreshList();
        });
        // 搜索
        $('#inviteCompanyEmpList-search-btn').click(function () {
            inviteCompanyEmpList_fn.reload(1);
        });
        // 重置
        $('#inviteCompanyEmpList-refresh-btn').click(function () {
            inviteCompanyEmpList_fn.resetSearch();
        });
        // 新增
        $('#inviteCompanyEmpList-add-btn').click(function () {
            cmsUtils.addContentTab('inviteCompanyEmpDetail', '员工管理-添加', '/piger/company/inviteCompanyEmpDetail.html', {
                list_fn: inviteCompanyEmpList_fn
            });
        });
    }
    // 工具条监听
    layui.table.on('tool(inviteCompanyEmpList-table)', function (obj) {
        switch (obj.event) {
            case 'edit':
                cmsUtils.addContentTab('inviteCompanyEmpDetail', '员工管理-编辑', '/piger/company/inviteCompanyEmpDetail.html', {
                    id: obj.data.id,
                    list_fn: inviteCompanyEmpList_fn
                });
                break;
            case 'delete':
                layer.confirm('确定删除该方案吗？', {
                    btn:['确定', '取消']
                }, function (index) {
                    var post_url = '/inviteCompanyEmp/delete/'+obj.data.id;
                    $.ajax({
                        type: 'delete',
                        url: post_url,
                        dataType: 'json',
                        success: function (data) {
                            layer.close(index);
                            if (data.code == 200) {
                                inviteCompanyEmpList_fn.reload(currPage);
                            } else {
                                layer.msg(data.msg, {anim: 6});
                            }
                        }
                    });
                });
                break;
            default:
                break;
        }
    });
});